<!-- 2023/10/23 淘系:新品筛选功能 -->
<script>
import baseMiXin from "@/views/robotOffice/task/mixin/baseMiXin";
import { deepClone } from "@/utils/service";

export default {
  name: "index",
  mixins: [baseMiXin],
  data() {
    return {
      form: {
        account: "",
        password: "",
        categoryList: [],
        dateCycle: "7天",
        handlerResultMode: 0,
        filterParam: {
          miniPayer: 10,
          g1MiniAmount: 10000,
          g1MiniUV: 3
        }
      },
      rules: {
        account: [
          {required: true, message: "请输入账号", trigger: "blur"}
        ],
        password: [
          {required: true, message: "请输入密码", trigger: "blur"}
        ],
        categoryList: [
          { type: 'array', required: true, message: '请至少选择一个目标类目', trigger: 'change' }
        ],
      },
      options: {
        category: ["漏勺", "汤勺", "全套勺铲", "砧板/菜板", "斩骨刀", "水果削皮器", "奶锅", "锅盖", "锅组套装",
          "蔬果刨丝器/瓜果刀", "菜刀", "全套厨房刀具", "小型燃气灶", "鱼鳞刨", "煎锅/平底锅", "厨房雕刻刀",
          "蒸格", "导热盘/解冻盘", "汤锅", "火锅炉", "烧水壶", "学生厨具套装", "压力锅/高压锅", "煎铲", "蒸锅",
          "炒锅", "砂锅/石锅", "其它", "油炸锅", "烹饪工具套装", "锅具可拆卸把手", "锅铲", "火锅", "汽锅",
          "炖锅/炖煲/汤煲", "多功能刀", "面包刀", "特殊用途刀", "冷冻调理刀", "木铲", "饭勺"],
        dateCycle: ["7天", "30天"]
      }
    };
  },
  methods: {
    deepClone,
    initParams({ account = "", password = "", categoryList = [], dateCycle = "7天", handlerResultMode = 0 }) {
      this.form.account = account;
      this.form.password = password;
      this.form.categoryList = categoryList;
      this.form.dateCycle = dateCycle;
      this.form.handlerResultMode = handlerResultMode;
    },
    checkParam() {
      let flag;
      this.$refs.form1.validate((valid) => flag = valid)
      return flag;
    },
    getParam() {
      return this.form;
    }
  }
};
</script>

<template>
  <div>
    <el-form ref="form1" :rules="rules" :model="form" :inline="true" label-suffix=" : " label-width="90px" size="mini">
      <el-form-item label="淘系账号" prop="account">
        <el-input v-model.trim="form.account" style="width: 320px;"></el-input>
      </el-form-item>
      <el-form-item label="淘系密码" prop="password">
        <el-input v-model.trim="form.password" style="width: 320px;" show-password></el-input>
      </el-form-item>
      <br />
      <el-form-item label="目标类目" prop="categoryList">
        <el-select style="width: 600px" v-model="form.categoryList" multiple placeholder="请选择目标类目" clearable
                   filterable>
          <el-option
            v-for="item in options.category"
            :key="item"
            :label="item"
            :value="item">
          </el-option>
        </el-select>
      </el-form-item>
      <br/>
      <el-form-item label="类目快捷选项" label-width="120px">
        <el-button  type="primary" style="margin-left: 5px" @click="form.categoryList = deepClone(options.category.filter(t => t.includes('锅')))">
          与锅相关
        </el-button>
        <el-button  type="primary" style="margin-left: 5px" @click="form.categoryList = deepClone(options.category.filter(t => t.includes('刀')))">
          与刀相关
        </el-button>
        <el-button  type="primary" style="margin-left: 5px" @click="form.categoryList = deepClone(options.category)">
          所有
        </el-button>
      </el-form-item>
      <br />
      <el-form-item label="数据周期" prop="dateCycle">
        <el-radio-group v-model="form.dateCycle">
          <el-radio label="7天"></el-radio>
          <el-radio label="30天"></el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="数据处理方式" prop="handlerResultMode" label-width="120px">
        <el-radio-group v-model="form.handlerResultMode">
          <el-radio :label=0>以任务报表附件返回</el-radio>
          <el-radio disabled :label=1>上传数据至服务器</el-radio>
        </el-radio-group>
      </el-form-item>
      <br />
      <el-divider content-position="left">
        <span style="font-size: 17px;font-weight: bold;letter-spacing: 0.1em">过滤条件</span>
      </el-divider>
      <el-form-item label="支付人数不能少于" prop="filterParam.miniPayer" label-width="150px">
        <el-input-number v-model="form.filterParam.miniPayer" :min="0"></el-input-number>
      </el-form-item>
      <el-divider><span>需要同时满足的条件 组1 </span></el-divider>
      <el-form-item label="交易金额不能少于" prop="filterParam.g1MiniAmount" label-width="150px">
        <el-input-number v-model="form.filterParam.g1MiniAmount" :min="0" :precision="2"></el-input-number>
      </el-form-item>
      <el-form-item label="UV价值不能少于" prop="filterParam.g1MiniUV" label-width="150px">
        <el-input-number v-model="form.filterParam.g1MiniUV" :min="0" :precision="2"></el-input-number>
      </el-form-item>
    </el-form>
  </div>
</template>

<style scoped>

</style>